package com.IO.Object;

import java.io.FileInputStream;
import java.io.ObjectInputStream;
import java.util.List;

/**
 * name：zhangwang
 * time：2025/3/12 13:51
 */
//反序列化多条数据
public class ObjectInputTestList {
    public static void main(String[] args)throws  Exception {
        //创建反序列化流
        ObjectInputStream inputStream = new ObjectInputStream(new FileInputStream("d.txt"));
        //读文件中的对象(强转)
       List<User> list = (List<User>) inputStream.readObject();
        //打印读到user对象
        for (User user : list) {
            System.out.println(user);
        }
        //释放资源
        inputStream.close();
    }
}
